package com.xmim.server.util;

import com.xmim.core.entity.UserDetail;
import com.xmim.core.session.user.UserSession;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

public class ChannelUtil {
    public static final AttributeKey<UserDetail> KEY_LOCAL_SESSION_USER = AttributeKey.valueOf("LOCAL_SESSION_USER");
    public static final AttributeKey<UserSession> KEY_LOCAL_SESSION = AttributeKey.valueOf("LOCAL_SESSION");

    public static <T> T getAttr(Channel channel, AttributeKey<T> attributeKey) {
        return channel.attr(attributeKey).get();
    }

    public static <T> void setAttr(Channel channel, AttributeKey<T> attributeKey, T t) {
        channel.attr(attributeKey).set(t);
    }
}
